package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PerformanceAssessment;
import com.ruoyi.system.service.IPerformanceAssessmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考核指标--DmyController
 *
 * @author 董明毅
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/jixiao/assessment")
public class PerformanceAssessmentController extends BaseController
{
    @Autowired
    private IPerformanceAssessmentService performanceAssessmentService;

    /**
     * 查询考核指标--Dmy列表
     */
    @PreAuthorize("@ss.hasPermi('jixiao:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(PerformanceAssessment performanceAssessment)
    {
        startPage();
        List<PerformanceAssessment> list = performanceAssessmentService.selectPerformanceAssessmentList(performanceAssessment);
        return getDataTable(list);
    }

    /**
     * 导出考核指标--Dmy列表
     */
    @PreAuthorize("@ss.hasPermi('jixiao:assessment:export')")
    @Log(title = "考核指标--Dmy", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PerformanceAssessment performanceAssessment)
    {
        List<PerformanceAssessment> list = performanceAssessmentService.selectPerformanceAssessmentList(performanceAssessment);
        ExcelUtil<PerformanceAssessment> util = new ExcelUtil<PerformanceAssessment>(PerformanceAssessment.class);
        util.exportExcel(response, list, "考核指标--Dmy数据");
    }

    /**
     * 获取考核指标--Dmy详细信息
     */
    @PreAuthorize("@ss.hasPermi('jixiao:assessment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(performanceAssessmentService.selectPerformanceAssessmentById(id));
    }

    /**
     * 新增考核指标--Dmy
     */
    @PreAuthorize("@ss.hasPermi('jixiao:assessment:add')")
    @Log(title = "考核指标--Dmy", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PerformanceAssessment performanceAssessment)
    {
        return toAjax(performanceAssessmentService.insertPerformanceAssessment(performanceAssessment));
    }

    /**
     * 修改考核指标--Dmy
     */
    @PreAuthorize("@ss.hasPermi('jixiao:assessment:edit')")
    @Log(title = "考核指标--Dmy", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PerformanceAssessment performanceAssessment)
    {
        return toAjax(performanceAssessmentService.updatePerformanceAssessment(performanceAssessment));
    }

    /**
     * 删除考核指标--Dmy
     */
    @PreAuthorize("@ss.hasPermi('jixiao:assessment:remove')")
    @Log(title = "考核指标--Dmy", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(performanceAssessmentService.deletePerformanceAssessmentByIds(ids));
    }
}
